export default {
    status(status) {
        switch (status) {
            case "1":
                return "已下发"
            case "2":
                return "转产中"
            case "3":
                return "转产完成"
            case "4":
                return "调机中"
            case "5":
                return "调机中断"
            case "6":
                return "调机完成"
            case "7":
                return "生产中"
            case "8":
                return "生产中断"
            case "9":
                return "生产完成"
            default:
                return "其他"
        }
    },
    productionStatus(status) {
        switch (status) {
            case "1":
                return "已下发"
            case "2":
                return "转产中"
            case "3":
                return "转产完成"
            case "4":
                return "调机中"
            case "5":
                return "调机中断"
            case "6":
                return "调机完成"
            case "7":
                return "生产中"
            case "8":
                return "生产中断"
            case "9":
                return "生产完成"
            default:
                return "其他"
        }
    },
    formatTimeDuration(millisecond) {
        if (millisecond < 0) {
            return '00:00:00';
        }
        let second = parseInt(millisecond / 1000);
        let minute = 0;
        let hour = 0;
        let day = 0;
        if (second > 60) {
            minute = parseInt(second / 60);
            second = parseInt(second % 60);
            if (minute > 60) {
                hour = parseInt(minute / 60);
                minute = parseInt(minute % 60);
                if (hour > 24) {
                    day = parseInt(hour / 24);
                    hour = parseInt(hour % 24);
                }
            }
        }
        return day > 0 ?
            `${day}天 ${hour>=10?hour:'0'+hour}:${minute>=10?minute:'0'+minute}:${second>=10?second:'0'+second}` :
            `${hour>=10?hour:'0'+hour}:${minute>=10?minute:'0'+minute}:${second>=10?second:'0'+second}`;
    },
    formatCurrentTimeDuration() {
        const year = new Date().getFullYear();
        const month = new Date().getMonth() + 1;
        const day = new Date().getDate();
        const millisecondStart = new Date(
            year + "-" + month + "-" + day + " 00:00:00"
        ).getTime();
        const millisecondEnd = new Date().getTime();
        const millisecond = millisecondEnd - millisecondStart;
        if (millisecond < 0) {
            return "00:00";
        }
        let second = parseInt(millisecond / 1000);
        let minute = 0;
        let hour = 0;
        if (second > 60) {
            minute = parseInt(second / 60);
            second = parseInt(second % 60);
            if (minute > 60) {
                hour = parseInt(minute / 60);
                minute = parseInt(minute % 60);
                if (hour > 24) {
                    hour = parseInt(hour % 24);
                }
            }
        }
        return `${hour >= 10 ? hour : "0" + hour}:${
        minute >= 10 ? minute : "0" + minute
      }:${second >= 10 ? second : "0" + second}`;
    },
};